import $axios from 'utils/Request'

/**
 * 获取角色组列表
 */
export const getRoleGroupPage = data => {
    return $axios({
        url: '/api/rule-group-do/v1',
        method: 'get',
        data
    });
}

/**
 * 获取角色组
 */
export const getRoleGroupList = data => {
    return $axios({
        url: '/api/rule-group-do/v1/list',
        method: 'get',
        data
    });
}

/**
 * 获取角色组详情
 * @param {id} data 
 */
export const getRoleGroupById = data => {
    return $axios({
        url: '/api/rule-group-do/v1/' + data.id,
        method: 'get',
        data
    });
}

/**
 * 保存角色组
 * @param {*} data 
 */
export const saveRoleGroup = data => {
    return $axios({
        url: '/api/rule-group-do/v1',
        method: 'post',
        data
    });
}

/**
 * 删除角色组
 * @param {id} data 
 */
export const deleteRoleGroupById = data => {
    return $axios({
        url: '/api/rule-group-do/v1/' + data.id,
        method: 'delete',
        data
    });
}

/**
 * 修改角色组信息
 * @param {*} data 
 */
export const updateRoleGroupById = data => {
    return $axios({
        url: '/api/rule-group-do/v1/' + data.id,
        method: 'put',
        data
    });
}

/**
 * 获取角色列表
 */
export const getRolePage = data => {
    return $axios({
        url: '/api/rule-do/v1',
        method: 'get',
        data
    });
}

/**
 * 获取角色
 */
export const getRoleList = data => {
    return $axios({
        url: '/api/rule-do/v1/list',
        method: 'get',
        data
    });
}

/**
 * 获取角色详情
 * @param {*} data 
 */
export const getRoleById = data => {
    return $axios({
        url: '/api/rule-do/v1/' + data.id,
        method: 'get',
        data
    });
}

/**
 * 保存角色
 * @param {*} data 
 */
export const saveRole = data => {
    return $axios({
        url: '/api/rule-do/v1',
        method: 'post',
        data
    });
}

/**
 * 删除角色
 * @param {*} data 
 */
export const deleteRoleById = data => {
    return $axios({
        url: '/api/rule-do/v1/' + data.id,
        method: 'delete',
        data
    });
}

/**
 * 修改角色信息
 * @param {*} data 
 */
export const updateRoleById = data => {
    return $axios({
        url: '/api/rule-do/v1/' + data.id,
        method: 'put',
        data
    });
}
/**
 * 修改角色
 * @param {*} data 
 */
export const patchRoleById = data => {
    return $axios({
        url: '/api/rule-do/v1/' + data.id,
        method: 'patch',
        data
    });
}

/**
 * 得到当前角色已经授权的资源
 * @param {*} data 
 */
export const getPermissionIdListByRuleId = data => {
    return $axios({
        url: '/api/rule-permission-do/v1/' + data.ruleId,
        method: 'get',
        data
    });
}

/**
 * 保存角色授权
 * @param {*} data 
 */
export const saveRulePermission = data => {
    return $axios({
        url: '/api/rule-permission-do/v1',
        method: 'post',
        data
    });
}

/**
 * 得到所有的角色列表
 * @param {*} data 
 */
export const getTree = data => {
    return $axios({
        url: '/api/rule-group-do/v1/getTree',
        method: 'get',
        data
    });
}